import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import notice from "./notice"
import user2 from "./user2"
import type from "./type"

const state = {
    count: 0
}
const mutations = {
    jia(state) {
        state.count++
    },
    jian(state) {
        state.count--
    }
}
const actions = {
    Ajia(context) {
        context.commit('jia')
    },
    Ajian(context) {
        context.commit('jian')
    },
    Aevenjia({ commit, state }) {
        if (state.count % 2 == 0) {
            commit('jia')
        }
    },
    Atimejia(context) {
        setTimeout(() => {
            context.commit('jia')
        }, 1000);
    }
}
const getters = {
    oddOrEven(state) {
        return state.count % 2 == 0 ? '偶数' : '奇数';
    }
}
const store = new Vuex.Store({
    state,
    mutations,
    actions,
    getters,
    modules:{
        notice,
        user2,
        type
    }
})

export default store
